package com.hontech.bv.ui.fragment.pearl

import android.view.View
import com.hontech.bv.R
import com.hontech.bv.model.pearl.PearlStatus
import com.hontech.bv.ui.view.NumberSensorView
import com.hontech.bv.ui.view.SwitchSensorView

class StatusDelegate(view: View) {

    private val swDropBox = view.findViewById<SwitchSensorView>(R.id.id_pearl_sw_drop_box)
    private val swPickBoxTop = view.findViewById<SwitchSensorView>(R.id.id_pearl_sw_pick_box_top)
    private val swPickBoxBottom = view.findViewById<SwitchSensorView>(R.id.id_pearl_sw_pick_box_bottom)
    private val swDumpBoxTop = view.findViewById<SwitchSensorView>(R.id.id_pearl_sw_dump_box_top)
    private val swDumpBoxBottom = view.findViewById<SwitchSensorView>(R.id.id_pearl_sw_dump_box_bottom)
    private val swPickOrigin = view.findViewById<SwitchSensorView>(R.id.id_pearl_sw_pick_origin)
    private val swCargoOrigin = view.findViewById<SwitchSensorView>(R.id.id_pearl_sw_cargo_origin)
    private val swPickAlm = view.findViewById<SwitchSensorView>(R.id.id_pearl_sw_pick_alm)
    private val swCargoAlm = view.findViewById<SwitchSensorView>(R.id.id_pearl_sw_cargo_alm)

    private val adc = view.findViewById<NumberSensorView>(R.id.id_pearl_nsv_adc)

    fun update() {
        val status = PearlStatus.status
        val sw = status.getSwitchValue()
        swDropBox.set(sw.isDropBox)
        swPickBoxTop.set(sw.isPickBoxTop)
        swPickBoxBottom.set(sw.isPickBoxBottom)
        swDumpBoxTop.set(sw.isDumpBoxTop)
        swDumpBoxBottom.set(sw.isDumpBoxBottom)
        swPickOrigin.set(sw.isPickOrigin)
        swCargoOrigin.set(sw.isCargoOrigin)
        swPickAlm.set(sw.isPickAlm)
        swCargoAlm.set(sw.isCargoAlm)
        adc.set(status.adc.value)
    }


}